package WaiBao;

import java.util.Arrays;

public class JingChenXiang {
    public static void main(String[] args) {
        String[] name = {"李晓(班长)", "肖战(副班长)", "小李(学习委员)", "荔枝村(组织委员)", "张凯智", "王自力", "李潇", "关婷婷", "李浩楠", "张多多", "李佳航", "张老布",
                "李达", "高育良", "沙瑞金", "李天栋", "田浩旺", "曾正", "姜武", "王千源", "欧豪", "欧阳修", "白居易", "放置类", "耿两份", "宋仲基", "李道华", "张柏芝",
                "林黛玉", "晋晨祥(学生)"};//考生本人:晋晨祥(学生)
        int[] age = {19, 18, 20, 19, 20, 21, 21, 21,20, 19, 18, 18, 18, 20, 21, 19, 18, 19, 18, 20, 19, 19, 20, 20, 20, 18, 20, 19, 18, 21};//考生年龄：21

        double[] tong1 = {79, 74, 85, 80, 81, 69, 78, 99, 60, 80, 94, 87, 85, 79, 64, 68, 69, 99, 96, 88, 92, 91, 95, 85, 75, 74, 76, 89, 84, 95};
        double[] tong2 = {64, 85, 87, 65, 78, 87, 85, 69, 60, 80, 90, 67, 85, 75, 85, 65, 86, 79, 66, 78, 82, 71, 85, 85, 75, 89, 74, 72, 85, 97};
        double[] tong3 = {85, 85, 71, 65, 89, 75, 69, 69, 80, 60, 93, 87, 85, 85, 65, 98, 89, 79, 96, 63, 92, 81, 95, 85, 76, 88, 73, 78, 78, 94};

        double juzi1;//代表每个学生的总分
        double juzi2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            juzi1 = tong1[i] + tong2[i] +tong3[i];
//            juzi2 = (juzi1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + juzi1);
//            System.out.println(name[i] + "的平均分为:" + juzi2);
//        }

        double maomi1 = 0, maomi2 = 0;
        double[] dahlia = new double[30];
//        for (int i = 0; i < 30; i++) {
//            maomi1 = tong1[i] + tong2[i] + tong3[i];
//            maomi2 = ( maomi1 * 1.0) / 3;
//            dahlia[i] = maomi2;
//        }
//
//        for (int i = 0; i < dahlia.length - 1; i++) {
//            for (int j = 0; j < dahlia.length - i - 1; j++) {
//                if (dahlia[j] < dahlia[j + 1]) {
//                    double temp = dahlia[j];
//                    dahlia[j] = dahlia[j + 1];
//                    dahlia[j + 1] = temp;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(dahlia[i]);
//        }


        double baixie1 = 0,baixie2 = 0, baixie3 = 0;//计算每门课的平均分
        double crocus1 = 0, crocus2 = 0, crocus3 = 0;//计算每门课标准差
        double feicui1 = 0, feicui2 = 0, feicui3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i <tong1.length; i++) {
            sum2+=tong1[i];
        }
        baixie1 = (sum2*1.0)/30;
        System.out.println("分析化学的班级平均分为:"+baixie1);
        double Sum = 0;
        for (int i = 0; i < tong2.length; i++) {
            Sum+=tong2[i];
        }
        baixie2 = (Sum*1.0)/30;
        System.out.println("线性代数的班级平均分为:"+baixie2);
        double sum = 0;
        for (int i = 0; i <tong3.length; i++) {
            sum+=tong3[i];
        }
        baixie3 = (sum*1.0)/30;
        System.out.println("有机化学的班级平均分为:"+baixie3);


        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i < tong1.length; i++) {
            c1+= (tong1[i] -baixie1)*(tong1[i] - baixie1);
        }
        crocus1 = Math.sqrt(c1*1.0/30);
        System.out.println("分析化学的班级标准差为:"+ crocus1);

        for (int i = 0; i < tong2.length; i++) {
            c2+= (tong2[i] -baixie2)*(tong2[i] - baixie2);
        }
        crocus2 = Math.sqrt(c2*1.0/30);
        System.out.println("线性代数的班级标准差为:"+ crocus2);

        for (int i = 0; i < tong3.length; i++) {
            c3+= (tong3[i] - baixie3)*(tong3[i] -baixie3);
        }
        crocus3 = Math.sqrt(c3*1.0/30);
        System.out.println("有机化学的班级标准差为:"+ crocus3);
//
        Arrays.sort(tong1);
        Arrays.sort(tong2);
        Arrays.sort(tong3);
        feicui1 =( tong1[14]+tong1[15])*1.0/2;
        feicui2 =( tong2[14]+tong2[15])*1.0/2;
        feicui3 =( tong3[14]+tong3[15])*1.0/2;
        System.out.println("分析化学的中位数为:"+feicui1);
        System.out.println("线性代数的中位数为:"+feicui2);
        System.out.println("有机化学学的中位数为:"+feicui3);




    }
}
